// pages/constmer/address-list/index.js
Page({
  data: {
    data: [
      {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      },
      {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      }, {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      },
      {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      },
      {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      }, {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      },
      {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      },
      {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      },
      {
        phone: 123456789,
        address: '某某路150米',
        tag: '其他',
      }
    ],
    time: null,
    price: null,
    reward: null,
    coupon: null,
    lastPrice: null,
    addressId: null,
    carry: '',
    weight: '',
    worth: '',
    wareText: '',
    inputAddressText: '',
  },
  onLoad: function(option){
    var that = this;
    if (option.pagetype == 'largess'){
      that.setData({
        pagetype: option.pagetype,
        time: option.time,
        price: option.price,
        reward: option.reward,
        coupon: option.coupon,
        lastPrice: option.lastPrice,
        addressId: option.addressId,
        carry: option.carry,
        weight: option.weight,
        worth: option.worth,
        inputAddressText: option.inputAddressText,
      });
    }else{
      that.setData({
        pagetype: option.pagetype,
        time: option.time,
        price: option.price,
        reward: option.reward,
        coupon: option.coupon,
        lastPrice: option.lastPrice,
        addressId: option.addressId,
        wareText: option.wareText,
        inputAddressText: option.inputAddressText,
      });
    }
    
  },
  checkItem: function (e) {
    var id = e.currentTarget.dataset.id;
    var that = this;
    that.setData({
      addressId: id
    });
    if (that.data.pagetype == 'largess'){
      wx.redirectTo({
        url: '/sd_liferuning/pages/constmer/largess/index?time=' + that.data.time + '&&price=' + that.data.price + '&&reward=' + that.data.reward + '&&coupon=' + that.data.coupon + '&&lastPrice=' + that.data.lastPrice + '&&addressId=' + that.data.addressId + '&&carry=' + that.data.carry + '&&weight=' + that.data.weight + '&&worth=' + that.data.worth + '&&inputAddressText=' + that.data.inputAddressText 
      })
    }else{
      wx.redirectTo({
        url: '/sd_liferuning/pages/constmer/buy/index?time=' + that.data.time + '&&price=' + that.data.price + '&&reward=' + that.data.reward + '&&coupon=' + that.data.coupon + '&&lastPrice=' + that.data.lastPrice + '&&addressId=' + that.data.addressId + '&&inputAddressText=' + that.data.inputAddressText + '&&wareText=' + that.data.wareText
      })
    }
    
  }

})